from django.db import models
from dingxiang_doctor.utils.basemodels import BaseModel
from disease.models import Department
from user.models import User

# Create your models here.
class Hospital(BaseModel):
    address = models.CharField(max_length=2000, verbose_name="医院地址")
    description = models.CharField(max_length=2000, verbose_name="医院简介")
    image = models.ImageField(upload_to="hospital_image/", default="hospital_image/default.png", verbose_name="医院图片")
    es_id = models.CharField(max_length=200, null=True, verbose_name="es_id")

    class Meta:
        db_table = "hospital"
        verbose_name_plural = "医院"

class Doctor(BaseModel):
    category_choices = {
        (0, "普通医师"),
        (1, "副主任医师"),
        (2, "主任医师")
    }

    description = models.CharField(max_length=2000, verbose_name="医生简介")
    category = models.SmallIntegerField(choices=category_choices, verbose_name="医生职称")
    specialty = models.CharField(max_length=2000, verbose_name="医生专长")
    doctor_avatar = models.ImageField(upload_to="doctor_avatar/", default="doctor_avatar/default.png", verbose_name="医生头像")
    hospital = models.ForeignKey(Hospital, on_delete=models.CASCADE, verbose_name="所属医院")
    department = models.ForeignKey(Department, null=True, on_delete=models.CASCADE, verbose_name="所属科室")
    price = models.IntegerField(default=60, verbose_name="价格")
    es_id = models.CharField(max_length=200, null=True, verbose_name="es_id")

    class Meta:
        db_table = "doctor"
        verbose_name_plural = "医生"

class History1(BaseModel):
    id = models.CharField(primary_key=True, max_length=200, verbose_name="id")
    user = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name="用户")
    doctor = models.ForeignKey(Doctor, on_delete=models.CASCADE, verbose_name="医生")
    content = models.TextField(verbose_name="咨询内容")
    class Meta:
        db_table = "history1"
        verbose_name_plural = "咨询记录"

class History2(BaseModel):
    id = models.CharField(primary_key=True, max_length=200, verbose_name="id")
    user = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name="用户")
    doctor = models.ForeignKey(Doctor, on_delete=models.CASCADE, verbose_name="医生")
    content = models.TextField(verbose_name="咨询内容")
    class Meta:
        db_table = "history2"
        verbose_name_plural = "咨询记录"

class History3(BaseModel):
    id = models.CharField(primary_key=True, max_length=200, verbose_name="id")
    user = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name="用户")
    doctor = models.ForeignKey(Doctor, on_delete=models.CASCADE, verbose_name="医生")
    content = models.TextField(verbose_name="咨询内容")
    class Meta:
        db_table = "history3"
        verbose_name_plural = "咨询记录"


